<template>
    <transition
      name="custom-classer-transition"
      enter-active-class="animated fadeInDown"
      leave-active-class="animated fadeOutUp"
    >
      <div class="modal-ctrl-body" v-show="addClassObj.isShow"
      >
        <div class="modal-ctrl-main odd-row-ctrl">
          <div class="modal-title">
            <p>新增重点人类型</p>
          </div>
          <div class="modal-ctrl-content">
            <div class="modal-row" >
              <div class="modal-form-key f-l indispensable">
                类型名称：
              </div>
              <input type="text" v-model="ModalData.typename" class="modal-text f-l">
            </div>

            <!--              <div class="modal-row" >
                            <div class="modal-form-key f-l indispensable">
                              类型键值：
                            </div>
                            <input type="text" v-model="ModalData.typekey" class="modal-text f-l">
                          </div>

                          <div class="modal-row" >
                            <div class="modal-form-key f-l indispensable">
                              类型：
                            </div>
                            &lt;!&ndash;<input type="number" v-model.number="ModalData.type" class="modal-text f-l input-number"  >&ndash;&gt;
                            <select name="" v-model.number="ModalData.type">
                              <option value="0">0</option>
                              <option value="1">1</option>
                            </select>
                          </div>-->
          </div>
          <div class="btns text-r">
            <button type="button" class="btn btn-default"  @click="close">取消</button>
            <button type="button" class="btn btn-info" @click="subBtn">确定</button>
          </div>
        </div>
      </div>
    </transition>
</template>

<script>
  export default {
    name: "addClassModel",
    props:["addClassObj"],
    data(){
      return {
        ModalData: {
          typename: '',       // 类型名称 ,
          type: 0,           // 重点人类型的类型 ,
          parentid: '',        //  父节点id
          isDelete: 0,        //  0 未删除 1 已删除
        }
      }
    },
    methods: {
      //关闭弹窗
      close(){
        this.$emit("addClassClose");
        this.clearData(); //关闭弹窗清除数据
      },
      //提交
      subBtn(){
        this.ModalData.parentid = this.addClassObj.parentid;
        // 父节点id为点击部门的id
        this.ModalData.typename = this.JPtool.subBlank(this.ModalData.typename);
        if(this.verifyForm.isNull(this.ModalData.typename)){
          this.s_alert('请输重点人类型名称！');
          // alert('请输重点人类型名称！');
          return false;
        }
        let userId = this.addClassObj.userId;
        let url = this.ControlObject+'/BS/ImportPersonType/'+userId;
        this.$axios({
          url: url,
          data: this.ModalData,
          method: 'post'
        })
          .then(res => {
            this.s_alert('新增成功');
            // alert('新增成功');
            this.clearData();
            this.close()
          })
          .catch(err => {
            this.s_alert('新增失败'+err.response.data.errorMsg);
            // alert('新增失败'+err.response.data.errorMsg);
          })
      },
      clearData(){
        this.ModalData = {
          typename: '',       // 类型名称 ,
          typekey: '',        // 类型键值,
          type: 0,           // 重点人类型的类型 ,
          parentid: '',        //  父节点id
          isDelete: 0,        //  0 未删除 1 已删除
        }
      }
    }
  }
</script>

<style scoped>
  .input-number {
    width: 60%;
  }
  .fadeInDown,.fadeOutUp{
    animation-duration: .500s;
  }
</style>
